package com.skt.common_hr.common.puremvc
{
	import com.skt.common_hr.common.Messages;
	import com.wcl.utils.AlertHelper;
	
	import org.puremvc.as3.multicore.interfaces.INotification;

	public class OverViewMediator extends CommonMediator
	{
		protected var basicInterestMessages:Array = [Messages.ACTIVATE_MODULE,
													Messages.QUERY_CLOSE_MODULE,
													Messages.CLOSE_MODULE,
													];
		
		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function OverViewMediator( name:String, viewComponent:Object )
        {
            super( name, viewComponent );
        }
		
		
		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		override public function handleNotification(note:INotification):void
		{
			trace(note.getName());
			switch(note.getName()) 
			{
				case Messages.ACTIVATE_MODULE:
					bActivated = true;
					activatedView();
					break;
				case Messages.QUERY_CLOSE_MODULE:
					queryCloseModule();
					break;
				case Messages.CLOSE_MODULE:
					bActivated = false;
					closedView();
					break;
				default:
					//trace("handleNotification of OverViewMediator");
					break;
			}
		}		
		
		override protected function initializeView():void 
		{
			super.initializeView();
			activatedView();
		}
		
		protected function activatedView():void
		{
			trace("ActiveModule at " + mediatorName);
			clearView();
		}
		
		
		protected function queryCloseModule():void
		{
			if(bDirty) {
				AlertHelper.showMsgYesNo("Close?", "확인", null, onMsgQueryCloseY, onMsgQueryCloseN);
			}
			else {
				 mainFacade.sendNotification(Messages.ADMIT_CLOSE_MODULE, this);
			}
			
		}
		
		protected function closedView():void
		{
			trace("closed at MyProfileMediator"+ mediatorName);
		}
		
		
		
 		/**
		 * 모듈 Close 확인 창을 사용자가 확인후 처리
		 *     - Close OK     : View에 종료처리 -> MainModule에 'CLOSE_MODULE' 전송
		 *	   - Close Cancel : 처리 없음 
		 * @param
		 * @return void
		 */
		private function onMsgQueryCloseY():void{
			mainFacade.sendNotification(Messages.ADMIT_CLOSE_MODULE, this);
		}
		
		private function onMsgQueryCloseN():void{
			mainFacade.sendNotification(Messages.DENY_CLOSE_MODULE, this);
		}

	}
}